/*
 * Copyright (c) 2010, Nikolaus Moll
 * All rights reserved.
 */
package net.miblounge.gradecalculator.core.interfaces;

import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import net.miblounge.gradecalculator.core.descriptors.modulelistitems.IndividualModule;
import net.miblounge.gradecalculator.core.descriptors.modulelistitems.Module;
import net.miblounge.gradecalculator.core.descriptors.modulelistitems.SelectableModuleLists;

//@XmlJavaTypeAdapter(ModuleAdapter.class)
@XmlJavaTypeAdapter(value=ModuleAdapter.class,type=IModuleListItem.class)
@XmlSeeAlso({Module.class, IndividualModule.class, SelectableModuleLists.class})
public interface IModuleListItem extends IModuleIdentificator, Comparable<IModuleListItem> {
	enum ModuleType { Module, IndividualModule, SelectableModuleLists }

	ModuleType getModuleType();
	String getName();
	float getECTS();
	int getSortOrder();
	int getHoursPerWeek();
}

class ModuleAdapter extends XmlAdapter<Object, IModuleListItem> {

	@Override
	public Object marshal(final IModuleListItem v) throws Exception {
        return v;
	}

	@Override
	public IModuleListItem unmarshal(final Object v) throws Exception {
    	return (IModuleListItem)v;
	}
}